﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Collections;
using System.Data.SqlClient;

namespace ClassLibrary1
{
    public class Images
    {
        DBHelper dbh = new DBHelper();
        public void UploadImages(string url, string id)
        {
            string sql = "INSERT INTO Images values('" + url + "','" + id + "')";
            dbh.executeNonQuery(sql);
        }

        public DataTable GetImageById(string id)
        {
            string sql = "SELECT imageUrl from Images WHERE userID ='" + id + "'";
            DataTable dtlist = dbh.executeDataTable(sql);
            return dtlist;
        }

        public bool CheckImage(string url,string id)
        {
            bool flag = false;
            string sql = "SELECT * FROM Images WHERE imageUrl='" + url + "' and userID='"+id+ "'";
            SqlDataReader reader = dbh.executeQuerySql(sql);
            if (reader.Read())
            {
                flag = true;
            }
            return flag;
        }
        
    }
}
